import pygame as pg

WIN_WIDTH = 400
WIN_HEIGHT = 600

pg.init()
window = pg.display.set_mode((WIN_WIDTH, WIN_HEIGHT))
pg.display.set_caption("Animation")
window.fill((255, 255, 255))
# 画一个静态圆
y = WIN_HEIGHT / 2
r = 50
flag = "zoom in"
pg.draw.circle(window, (255, 70, 90), (WIN_WIDTH / 2, y), r)
pg.display.flip()
while True:
    # 循环显示帧
    window.fill((255, 255, 255))
    # y += 0.1
    if r <= 100 and flag == "zoom in":
        if r == 100:
            flag = "zoom out"
        else:
            r += 0.5
    elif r >= 0 and flag == "zoom out":
        if r == 0:
            flag = "zoom in"
        else:
            r -= 0.5

    pg.draw.circle(window, (255, 70, 90), (WIN_WIDTH / 2, y), r)
    pg.display.update()
    for event in pg.event.get():
        if event.type == pg.QUIT:
            exit()
